Installation
************

There are two ways to run Hydra Paste. The first way is to run Hydra Paste locally
on your own machine for debugging and experimental use. The second way is to run
Hydra Paste on a standalone server such as the `main server`_.  This page will
detail how to do both.

.. _main server: http://paste.hydra.ws/

Local Instance (for Development)
================================

First, install the required modules, ::

    sudo pip3 install python-magic dataset bottle
    sudo pip install sphinx # Only needed to build documentation
    sudo apt-get install python3-pygments  # Or your distro equivalent

Now, run the damn thing! ::

    cd hydrapaste/
    chmod +x hydrapaste.py
    ./hydrapaste.py --dev

    # Or, you can manually specify a ROOT for the server like this:
    ./hydrapaste.py --dev /home/you/dev/your/server/path
    
Now open up `this link`_ in your web browser.  If you see some headers, everything
is working.  You may need to change the address from ``localhost`` if you've got a
non-standard network configuration on your computer.

.. _this link: http://localhost:9090/test
    
Deployment to a Server
======================

In production, Hydra Paste is behind a reverse proxy behind `lighttpd`_.

.. _lighttpd: http://lighttpd.net

First, install Python dependencies and lighttpd ::

    sudo pip3 install python-magic dataset bottle
    sudo pip install Sphinx # if Python3.3 and up aren't on your machine
    #sudo pip3 install Sphinx # if Python 3.3 and up IS available on your machine
    sudo apt-get install lighttpd  # Or your distro equivalent
    sudo apt-get install python3-pygments # or your distro equivalent

Next, make ``hydrapaste.py`` and ``deploy`` executable if they aren't already. ::

    chmod +x hydrapaste.py deploy

Next is edit the ``deploy`` scriptand create any necessary directories. Also, edit the lighttpd
configuration so it runs as a reverse proxy for ``127.0.0.1:9090``.  You may also find it
benficial to setup lighttpd so it directly serves the ``/static/`` directories, and have it
automatically forward ``/favicon.ico`` and ``index.html`` from their appropriate locations.
Another important thing to note is that db.sqlite should **not** be accessible from the
web, as it holds user password hashes and all of your files. ::

    vim deploy  # Edit deploy if you have a non-standard setup
    mkdir -p /var/www/p/{doc,static,files}  # If you haven't already made these
    sudo vim /etc/lighttpd/lighttpd.conf

Now restart lighttpd, deploy your static files, and run ``hydrapaste.py`` ::

    sudo service lighttpd restart  # Or your distro's equivalent
    ./deploy

    Deploying files to "/var/www/p/"  # Will be different if you edited deploy
    # Output omitted
    "Deploy Success! Now run `./hydrapaste.py`!"

    ./hydrapaste.py

And now you've got a functioning paste server!

To update your server with any changes to template or configuration files, run the ``deploy``
script again, and restart ``hydrapaste.py``.
